package main

import (
	"context"
	"fmt"
	pb "gostu/grpc_stu/try_and_study/hello_grpc/proto"

	"google.golang.org/grpc"
	"google.golang.org/grpc/grpclog"
)

const (
	Address = "127.0.0.1:50052"
)

func main() {
	// 先建立连接
	conn, err := grpc.Dial(Address, grpc.WithInsecure())
	if nil != err {
		grpclog.Fatalln(err)
	}
	defer conn.Close()

	// 初始化客户端
	c := pb.NewHelloClient(conn)

	// 调用方法
	req := &pb.HelloRequest{Name: "---===grpc=="}
	res, err := c.SayHello(context.Background(), req)

	if nil != err {
		grpclog.Fatalln(err)
	}

	grpclog.Infoln(res)
	// grpclog.Println(res)
	fmt.Println(res)
}
